<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;


use app\common\model\LotteryPlayType;
use app\common\model\LotteryType;

/**
 * 玩法控制器
 */
class LotteryPlay extends AdminBase
{

    /**
     * 玩法列表
     */
    public function LotteryPlayList()
    {

        $where = $this->logicLotteryPlay->getWhere($this->param);
        $where['a.is_old']=0;
        $this->param['cate_id']=$where['a.cate_id'];
        $this->assign('list', $this->logicLotteryPlay->getLotteryPlayList($where, 'a.*,c.name as category_name', 'a.create_time desc'));
        $this->assign('cate',LotteryType::all(['status'=>1]));
        $this->assign('param',$this->param);
        return $this->fetch('lottery_play_list');
    }

    /**
     * 传统玩法列表
     */
    public function OldLotteryPlayList()
    {

        $where = $this->logicLotteryPlay->getWhere($this->param);
        $where['a.is_old']=1;
        $this->param['cate_id']=$where['a.cate_id'];
        $this->assign('list', $this->logicLotteryPlay->getLotteryPlayList($where, 'a.*,c.name as category_name', 'a.create_time desc'));
        $this->assign('cate',LotteryType::all(['status'=>1]));
        $this->assign('param',$this->param);
        return $this->fetch('old_lottery_play_list');
    }

    /**
     * 玩法添加
     */
    public function LotteryPlayAdd()
    {

        $this->LotteryPlayCommon();
        $this->assign('cate',LotteryType::all(['status'=>1]));
        $this->assign('play_cate',LotteryPlayType::all(['status'=>1,'is_old'=>$this->param['is_old']]));
        return $this->fetch('lottery_play_edit');
    }

    /**
     * 玩法编辑
     */
    public function LotteryPlayEdit()
    {

        $this->LotteryPlayCommon();

        $info = $this->logicLotteryPlay->getLotteryPlayInfo(['a.id' => $this->param['id']], 'a.*,c.name as category_name');
        $this->assign('play_cate',LotteryPlayType::all(['status'=>1,'is_old'=>$this->param['is_old']]));
        $this->assign('cate',LotteryType::all(['status'=>1]));
        $this->assign('info', $info);

        return $this->fetch('lottery_play_edit');
    }



    /**
     * 玩法分类编辑
     */
    public function LotteryCatePlayEdit()
    {

        IS_POST && $this->jump($this->logicLotteryPlay->LotteryPlayCateEdit($_POST));

        $info = $this->logicLotteryPlay->getLotteryPlayCateInfo(['a.id' => $this->param['id']], 'a.*');
        $this->assign('info', $info);

        return $this->fetch('lottery_play_cate_edit');
    }


    /**
     * 玩法分类列表
     */
    public function LotteryPlayCateList()
    {
            $where=[];
        !empty($this->param['search_data'])  && $where['name|description']=['like','%'.$this->param['search_data'].'%'];
        $this->assign('list', $this->logicLotteryPlay->getLotteryPlayCateList($where, 'a.*', 'a.create_time desc'));
        return $this->fetch('lottery_play_cate_list');
    }

    /**
     * 玩法分类添加
     */
    public function LotteryPlayCateAdd()
    {

        IS_POST && $this->jump($this->logicLotteryPlay->LotteryPlayCateEdit($_POST));

        return $this->fetch('lottery_play_cate_edit');
    }



    /**
     * 玩法添加与编辑通用方法
     */
    public function LotteryPlayCommon()
    {

        IS_POST && $this->jump($this->logicLotteryPlay->LotteryPlayEdit($_POST));
        $this->assign('is_old',  $this->param['is_old']);
        $this->assign('param',  $this->param);
    }






    /**
     * 数据状态设置
     */
    public function setStatus()
    {

        $this->jump($this->logicAdminBase->setStatus('LotteryPlay', $this->param));
    }
    /**
     * 数据状态设置
     */
    public function CatesetStatus()
    {

        $this->jump($this->logicAdminBase->setStatus('LotteryPlayType', $this->param));
    }

    /**
     * 数据状态设置
     */
    public function update_info()
    {
        $this->jump($this->logicLotteryPlay->update_info($this->param));
    }




}
